import request from '@/utils/request';

/**
 * 上传文件
 * @param file 文件
 */
export async function uploadFile(file, config) {
  const formData = new FormData();
  formData.append('file', file);
  const res = await request.post('/admin/cms/common/upload', formData, config);
  if (res.data.code === 200) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}
